package com.dc.business.datacollectbusiness.controller;

import com.dc.business.datacollectbusiness.entity.CollectorPassage;
import com.dc.business.datacollectbusiness.model.Result;
import com.dc.business.datacollectbusiness.service.CollectorPassageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/collectorpassage")
@CrossOrigin
public class CollectorPassageController {
    @Autowired
    private CollectorPassageService collectorPassageService;
    @GetMapping("/{collectorCode}")
    public Result getCollectorPassage(@PathVariable String collectorCode) {
        try {
            List<CollectorPassage> collectorPassageList=collectorPassageService.getCollectorPassageByCollectorCode(collectorCode);
            return Result.success(collectorPassageList);
        }catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }
    @PutMapping("/updatecollectorpassage")
    public Result updateCollectorPassage(@RequestBody CollectorPassage collectorPassage) {
        try {
            collectorPassageService.updateCollectorPassage(collectorPassage);
            return Result.success();
        }catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }


}
